package com.usian.kotlin

import javafx.collections.transformation.SortedList

class MyFrirstKotlin {
var a:Int=41
    var c:Int=10

    //数组
    var t= intArrayOf(1,5,6)
    //字符串
    var string:String="abcdefgh";
  val tt: Int =string.indexOf("c")
val substring=string.substring(0,1)
}
fun get(){
    var a:Int=8
    val toString = a.toString()
    val toByte = a.toByte()
    val toFloat = a.toFloat()
    if (a is Any){
        println(a)
        println(toString)
        println(toByte)
        println(toFloat)
    }
}

fun main(){
    //队列遍历
val list= mutableListOf<String>()
    list.add("11")
     list.add("22")
     list.add("33")
    val add = list.add("44")

    println(add)
    println("---------------------")
  var list2=  list.sortDescending()
   list.forEach {
       println("$it")
   }
    println("---------------------")

    /*  list.forEach {
         println("${list[1]}"+"$it")
       }*/
    //队列的循环
    for (i in 0 until list.size){
        println("${list[i]}")
        println("++++++++++")
    }
    //两种循环没有什么区别,但是使用下面的要注意索引越界问题
    for (i in 0 .. list.size-1)  println("${list[i]}")
//队列排序
    var desc=""
    var cribe=""
    //map
  var map= mutableMapOf<String,String>()
    map.put("张三","25")
    map.put("李四","88")
    map.put("王五","295")
    map.put("赵六","250")

if (map.containsKey("张三")) println("true")else {
    println("false")
}
/*    var booValue=true
    var button1=""
    if (booValue){
        button1.text = "true"
    } else{
        button1.text = "false"
    }
    button1.text = if(booValue) "true" else "false"*/
    //类型判断is
    var isContent=8
    if (isContent is Int){
        toast("我是int值")
    } else {
        toast("我是float值")
    }
    when(isContent){
        is Int -> toast("我是int值")
        else -> toast("我是float值")
    }
    if (list.isEmpty()) toast("集合为空")else{
        toast("集合不为空")}
if (map===list) toast("集合相等")else{
    toast("集合不相等")}

}

fun toast(s: Any) {

println("$s")
}

//kotlin函数
fun getDate(){
    toast("我没有返回值")
}
fun getDate2():Unit{
    toast("我任然没有返回值")
}
fun getdate3(content1:String,tontent2:String):String {
    val content:String=tontent2.toString()
    toast(content)
    return content
}
fun forUse(a : String ,b:String):Boolean{
    var bo = a.length>b.length
    return bo
}
fun foruse(a:String,b:String):Boolean{
    return a.length>b.length
}







